Indexes a collection by an expression (typically, by a field), providing fast access to items having particular values (or range of values) of that expression.

Namespace:  C1.LiveLinq.Indexing
Assembly:  C1.LiveLinq (in C1.LiveLinq.dll)

Syntax

C#
public abstract class Index<T, TKey> : Index<T>, 
	IInternalIndexScanner<T, TKey>, IIndexScanner<T, TKey>, IIndexScanner<T>
Visual Basic
Public MustInherit Class Index(Of T, TKey) _
	Inherits Index(Of T) _
	Implements IInternalIndexScanner(Of T, TKey), IIndexScanner(Of T, TKey),  _
	IIndexScanner(Of T)

Type Parameters

T
The type of the elements of the collection to index.
TKey
The type of the index key.

Remarks

Indexes can be created and added to a collection explicitly in code by calling IndexCollection.Add, or their creation can be enforced in LINQ queries by using the Indexed hint.

In LINQ queries, indexes are used for optimizing query performance if that is specified with an Indexed hint. Usually, hints are not required, because LiveLinq can automatically determine that an index can be used to speedup a query, but using hints helps to ensure this optimization.

Indexes can also be used programmatically in code, without LINQ syntax, by using the methods of the IIndexScanner<(Of <(<'T, TKey>)>)> interface that is implemented by the Index<(Of <(<'T, TKey>)>)> class. For example, you can call such methods as Find directly for an Index<(Of <(<'T, TKey>)>)> object.

It must be kept in mind that every index you create introduces a trade-off: it can dramatically speed up searches, but it consumes memory and adds some (usually, small) overhead every time the indexed collection (or any of the items, its elements) is modified. This is why indexes should generally be kept only while you need them for queries. To delete an index, use IndexCollection.Remove.

An index can have subindexes, see Subindex<(Of <(<'T, TKey>)>)>. Subindexes are optional, not required for any indexing tasks, but can provide additional optimization and help minimize memory requirements when a collection is indexed by multiple keys. In presence of subindexes, an index is the root level of a tree of subindexes.

Inheritance Hierarchy

System..::..Object
  C1.LiveLinq.Indexing..::..IndexDefinition<(Of <(<'T>)>)>
    C1.LiveLinq.Indexing..::..Index<(Of <(<'T>)>)>
      C1.LiveLinq.Indexing..::..Index<(Of <(<'T, TKey>)>)>

See Also